package org.atovio.structure.graph;

import org.atovio.structure.matrix.Matrix;

/**
 * @author AtoVio, Winter Yuan
 * @version 1.0
 */
public class MatrixGraph<T> extends AbstractGraph<T> {

    /*
    矩阵对象，存储邻接矩阵
     */
    protected Matrix matrix;

    public MatrixGraph() {
        super();
        this.matrix = new Matrix(0, 0);
    }

    /**
     * 以vertexes顶点集合构造图，边集合为空
     *
     * @param vertexes 定点集合
     */
    public MatrixGraph(T[] vertexes) {
        this();
        for (int i = 0; i < vertexes.length; i++)
            this.insert(vertexes[i]);
    }

    public MatrixGraph(T[] vertexes, Triple[] edges) {
        this(vertexes);
//        for (int j = 0; j < edges.length; j++)
            //this.insert(edges[j]); // 此处报错了
    }

    @Override
    public String toString() {
        StringBuilder str = new StringBuilder(super.toString() + "邻接矩阵：\n");
        int n = this.vertexCount();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (this.matrix.get(i, j) == MAX_WEIGHT)
                    str.append("    ∞"); // \u221E
                else
                    str.append(String.format("%dd", this.matrix.get(i, j)));
            }
            str.append("\n");
        }
        return str.toString();
    }

    @Override
    public int insert(T value) {
        return 0;
    }

    @Override
    public void insert(int i, int j, int w) {

    }

    @Override
    public T remove(int i) {
        return null;
    }

    @Override
    public void remove(int i, int j) {

    }

    @Override
    public int weight(int i, int j) {
        return 0;
    }

    @Override
    public void DFSTraverse(int i) {

    }

    @Override
    public void BFSTraverse(int i) {

    }

    @Override
    public void minSpanTree() {

    }

    @Override
    public void shortestPath(int i) {

    }

    @Override
    public void shortestPath() {

    }
}
